﻿using Compiler.Primitives;
using System.Collections.Generic;
using System.Linq;

namespace Compiler
{
    class Hub
    {
        private static readonly List<Class> Classes = new List<Class>();
        private static string _sourceFile = "";

        public static List<Class> GetClasses()
        {
            return Classes;
        }

        public static Class GetClass(string className) 
        {
            return Classes.FirstOrDefault(x => x.GetName() == className);
        }

        public static Function GetFunction(string className, string funcName)
        {
            return GetClass(className).GetFunctions().FirstOrDefault(x => x.GetName() == funcName);
        }

        public static void AddClass(Class newClass)
        {
            Classes.Add(newClass);
        }

        public static void SetSource(string src)
        {
            _sourceFile = src;
        }

        public static string GetSource()
        {
            return _sourceFile;
        }
    }
}
